
#include "zen_vap_combination.h"

namespace Zen { namespace Vap {
	
	Combination::Combination()
	{
		
	}

	void Combination::ready()
	{
		if(m_nodes.empty()) return;

		this->validateSubNodesOrder();
		for(auto i : m_nodes) { if(i->isVisible()) i->ready(); }
	}
	void Combination::draw()
	{
		for(auto i : m_nodes) { if(i->isVisible()) i->draw(); }
	}
	
	Combination2D::Combination2D()
	: Node2D(), PartOfMatrix2D(false)
	{
	}
	
	void Combination2D::ready()
	{
		if(m_nodes.empty() || !isVisible()) return;
		this->validateSubNodesOrder();
		for(auto i : m_nodes) { if(i->isVisible()) i->ready(); }
	}
	
	void Combination2D::draw()
	{
		if(m_nodes.empty() || !isVisible()) return;
		
		DrawStack::GuardMatrix __gm(&this->getMatrix(), getMatrixVersion());
		DrawStack::GuardAlpha __ga(this->getAlpha());
		DrawStack::GuardBlend __gb(this->getBlend());
		
		for(auto i : m_nodes) { if(i->isVisible()) i->draw(); }
	}
	
	Combination3D::Combination3D()
	: Node3D()
	{
	}
	
	void Combination3D::ready()
	{
		this->validateSubNodesOrder();
		for(auto i : m_nodes) { if(i->isVisible()) i->ready(); }
	}
	void Combination3D::draw()
	{
		if(m_nodes.empty()) return;
		
		DrawStack::GuardMatrix __gm(&this->getMatrix(), getMatrixVersion());
		
		for(auto i : m_nodes) { if(i->isVisible()) i->draw(); }
		
	}
}}
